package com.eduhzy.ttw.clazz.mvp.model.entity;

import android.content.Context;
import android.os.Parcel;
import android.os.Parcelable;

/**
 * @author xubo
 * @date 2018/12/4 17:09
 */
public class ClazzScoreData implements Parcelable {

    /**
     * iconUrl :
     * score : 0
     * scoreType : 0
     * sequence : 0
     * tagId : 0
     * title :
     */

    private int iconUrl;
    private int score;
    private int scoreType;
    private int sequence;
    private int tagId;
    private String title;
    private int resIcon;
    boolean edit;

    public boolean isEdit() {
        return edit;
    }

    public void setEdit(boolean edit) {
        this.edit = edit;
    }

    public int getResIcon() {
        return resIcon;
    }

    public void setResIcon(int resIcon) {
        this.resIcon = resIcon;
    }

    public int getIconUrl(Context mContext) {
        int drawable = mContext.getResources().getIdentifier("icon_" + iconUrl, "drawable", mContext.getPackageName());
        return drawable;
    }

    public void setIconUrl(int iconUrl) {
        this.iconUrl = iconUrl;
    }

    public int getScore() {
        return score;
    }

    public void setScore(int score) {
        this.score = score;
    }

    public int getScoreType() {
        return scoreType;
    }

    public void setScoreType(int scoreType) {
        this.scoreType = scoreType;
    }

    public int getSequence() {
        return sequence;
    }

    public void setSequence(int sequence) {
        this.sequence = sequence;
    }

    public int getTagId() {
        return tagId;
    }

    public void setTagId(int tagId) {
        this.tagId = tagId;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public ClazzScoreData() {
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(this.iconUrl);
        dest.writeInt(this.score);
        dest.writeInt(this.scoreType);
        dest.writeInt(this.sequence);
        dest.writeInt(this.tagId);
        dest.writeString(this.title);
        dest.writeInt(this.resIcon);
        dest.writeByte(this.edit ? (byte) 1 : (byte) 0);
    }

    protected ClazzScoreData(Parcel in) {
        this.iconUrl = in.readInt();
        this.score = in.readInt();
        this.scoreType = in.readInt();
        this.sequence = in.readInt();
        this.tagId = in.readInt();
        this.title = in.readString();
        this.resIcon = in.readInt();
        this.edit = in.readByte() != 0;
    }

    public static final Creator<ClazzScoreData> CREATOR = new Creator<ClazzScoreData>() {
        @Override
        public ClazzScoreData createFromParcel(Parcel source) {
            return new ClazzScoreData(source);
        }

        @Override
        public ClazzScoreData[] newArray(int size) {
            return new ClazzScoreData[size];
        }
    };
}
